package cc.langk.web.mapper;

import cc.langk.web.entity.SysMenu;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface SysMenuMapper {
    @Delete({
        "delete from sys_menu",
        "where ROW_ID = #{rowId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long rowId);

    @Insert({
        "insert into sys_menu (PARENT_ID, MENU_CODE, ",
        "MENU_NAME, MENU_DESC, ",
        "URL, ICON, MENU_FLAG, ",
        "DEL_FLAG, IP_LIMIT_FLAG, ",
        "LEAF_FLAG, OPEN_WAY, ",
        "ORDER_NUM, USE_FLAG, ",
        "CREATE_TIME, CREATE_ID, ",
        "CREATE_ACCOUNT, OPT_ID, ",
        "OPT_ACCOUNT, OPT_TIME, ",
        "OPT_TIME1, HELP_CONTENT)",
        "values (#{parentId,jdbcType=BIGINT}, #{menuCode,jdbcType=VARCHAR}, ",
        "#{menuName,jdbcType=VARCHAR}, #{menuDesc,jdbcType=VARCHAR}, ",
        "#{url,jdbcType=VARCHAR}, #{icon,jdbcType=VARCHAR}, #{menuFlag,jdbcType=SMALLINT}, ",
        "#{delFlag,jdbcType=SMALLINT}, #{ipLimitFlag,jdbcType=SMALLINT}, ",
        "#{leafFlag,jdbcType=SMALLINT}, #{openWay,jdbcType=VARCHAR}, ",
        "#{orderNum,jdbcType=INTEGER}, #{useFlag,jdbcType=SMALLINT}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{createId,jdbcType=BIGINT}, ",
        "#{createAccount,jdbcType=VARCHAR}, #{optId,jdbcType=BIGINT}, ",
        "#{optAccount,jdbcType=VARCHAR}, #{optTime,jdbcType=TIMESTAMP}, ",
        "#{optTime1,jdbcType=TIMESTAMP}, #{helpContent,jdbcType=LONGVARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="rowId", before=false, resultType=Long.class)
    int insert(SysMenu record);

    @Select({
        "select",
        "ROW_ID, PARENT_ID, MENU_CODE, MENU_NAME, MENU_DESC, URL, ICON, MENU_FLAG, DEL_FLAG, ",
        "IP_LIMIT_FLAG, LEAF_FLAG, OPEN_WAY, ORDER_NUM, USE_FLAG, CREATE_TIME, CREATE_ID, ",
        "CREATE_ACCOUNT, OPT_ID, OPT_ACCOUNT, OPT_TIME, OPT_TIME1, HELP_CONTENT",
        "from sys_menu",
        "where ROW_ID = #{rowId,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="ROW_ID", property="rowId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="PARENT_ID", property="parentId", jdbcType=JdbcType.BIGINT),
        @Result(column="MENU_CODE", property="menuCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="MENU_NAME", property="menuName", jdbcType=JdbcType.VARCHAR),
        @Result(column="MENU_DESC", property="menuDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="URL", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="ICON", property="icon", jdbcType=JdbcType.VARCHAR),
        @Result(column="MENU_FLAG", property="menuFlag", jdbcType=JdbcType.SMALLINT),
        @Result(column="DEL_FLAG", property="delFlag", jdbcType=JdbcType.SMALLINT),
        @Result(column="IP_LIMIT_FLAG", property="ipLimitFlag", jdbcType=JdbcType.SMALLINT),
        @Result(column="LEAF_FLAG", property="leafFlag", jdbcType=JdbcType.SMALLINT),
        @Result(column="OPEN_WAY", property="openWay", jdbcType=JdbcType.VARCHAR),
        @Result(column="ORDER_NUM", property="orderNum", jdbcType=JdbcType.INTEGER),
        @Result(column="USE_FLAG", property="useFlag", jdbcType=JdbcType.SMALLINT),
        @Result(column="CREATE_TIME", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="CREATE_ID", property="createId", jdbcType=JdbcType.BIGINT),
        @Result(column="CREATE_ACCOUNT", property="createAccount", jdbcType=JdbcType.VARCHAR),
        @Result(column="OPT_ID", property="optId", jdbcType=JdbcType.BIGINT),
        @Result(column="OPT_ACCOUNT", property="optAccount", jdbcType=JdbcType.VARCHAR),
        @Result(column="OPT_TIME", property="optTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="OPT_TIME1", property="optTime1", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="HELP_CONTENT", property="helpContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    SysMenu selectByPrimaryKey(Long rowId);

    @Select({
        "select",
        "ROW_ID, PARENT_ID, MENU_CODE, MENU_NAME, MENU_DESC, URL, ICON, MENU_FLAG, DEL_FLAG, ",
        "IP_LIMIT_FLAG, LEAF_FLAG, OPEN_WAY, ORDER_NUM, USE_FLAG, CREATE_TIME, CREATE_ID, ",
        "CREATE_ACCOUNT, OPT_ID, OPT_ACCOUNT, OPT_TIME, OPT_TIME1, HELP_CONTENT",
        "from sys_menu"
    })
    @Results({
        @Result(column="ROW_ID", property="rowId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="PARENT_ID", property="parentId", jdbcType=JdbcType.BIGINT),
        @Result(column="MENU_CODE", property="menuCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="MENU_NAME", property="menuName", jdbcType=JdbcType.VARCHAR),
        @Result(column="MENU_DESC", property="menuDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="URL", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="ICON", property="icon", jdbcType=JdbcType.VARCHAR),
        @Result(column="MENU_FLAG", property="menuFlag", jdbcType=JdbcType.SMALLINT),
        @Result(column="DEL_FLAG", property="delFlag", jdbcType=JdbcType.SMALLINT),
        @Result(column="IP_LIMIT_FLAG", property="ipLimitFlag", jdbcType=JdbcType.SMALLINT),
        @Result(column="LEAF_FLAG", property="leafFlag", jdbcType=JdbcType.SMALLINT),
        @Result(column="OPEN_WAY", property="openWay", jdbcType=JdbcType.VARCHAR),
        @Result(column="ORDER_NUM", property="orderNum", jdbcType=JdbcType.INTEGER),
        @Result(column="USE_FLAG", property="useFlag", jdbcType=JdbcType.SMALLINT),
        @Result(column="CREATE_TIME", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="CREATE_ID", property="createId", jdbcType=JdbcType.BIGINT),
        @Result(column="CREATE_ACCOUNT", property="createAccount", jdbcType=JdbcType.VARCHAR),
        @Result(column="OPT_ID", property="optId", jdbcType=JdbcType.BIGINT),
        @Result(column="OPT_ACCOUNT", property="optAccount", jdbcType=JdbcType.VARCHAR),
        @Result(column="OPT_TIME", property="optTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="OPT_TIME1", property="optTime1", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="HELP_CONTENT", property="helpContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<SysMenu> selectAll();

    @Update({
        "update sys_menu",
        "set PARENT_ID = #{parentId,jdbcType=BIGINT},",
          "MENU_CODE = #{menuCode,jdbcType=VARCHAR},",
          "MENU_NAME = #{menuName,jdbcType=VARCHAR},",
          "MENU_DESC = #{menuDesc,jdbcType=VARCHAR},",
          "URL = #{url,jdbcType=VARCHAR},",
          "ICON = #{icon,jdbcType=VARCHAR},",
          "MENU_FLAG = #{menuFlag,jdbcType=SMALLINT},",
          "DEL_FLAG = #{delFlag,jdbcType=SMALLINT},",
          "IP_LIMIT_FLAG = #{ipLimitFlag,jdbcType=SMALLINT},",
          "LEAF_FLAG = #{leafFlag,jdbcType=SMALLINT},",
          "OPEN_WAY = #{openWay,jdbcType=VARCHAR},",
          "ORDER_NUM = #{orderNum,jdbcType=INTEGER},",
          "USE_FLAG = #{useFlag,jdbcType=SMALLINT},",
          "CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},",
          "CREATE_ID = #{createId,jdbcType=BIGINT},",
          "CREATE_ACCOUNT = #{createAccount,jdbcType=VARCHAR},",
          "OPT_ID = #{optId,jdbcType=BIGINT},",
          "OPT_ACCOUNT = #{optAccount,jdbcType=VARCHAR},",
          "OPT_TIME = #{optTime,jdbcType=TIMESTAMP},",
          "OPT_TIME1 = #{optTime1,jdbcType=TIMESTAMP},",
          "HELP_CONTENT = #{helpContent,jdbcType=LONGVARCHAR}",
        "where ROW_ID = #{rowId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(SysMenu record);
}